package com.aplink.dellcommercial.webservices;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;

public class HttpHelper {
    public static String ConvertStreamToString( InputStream is ) {
        if ( is != null ) {
            final Writer writer = new StringWriter();
            final char[] buffer = new char[1024];
            try {
                final Reader reader = new BufferedReader( new InputStreamReader( is,
                        "UTF-8" ) );
                int n;
                while ( ( n = reader.read( buffer ) ) != - 1 ) {
                    writer.write( buffer, 0, n );
                }
            } catch ( final IOException e ) {
                return "";
            }
            return writer.toString();
        } else {
            return "";
        }
    }

    private HttpHelper() {

    }
}